package com.heima.controller;

import com.heima.com.Student;
import com.heima.dao.StudentDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/AddServletStudent1")
public class StudentController extends HttpServlet {
      StudentDao studentDao =  new StudentDao();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String name = req.getParameter("username");
        System.out.println(name);
        String age = req.getParameter("age");
        int studentAge = Integer.parseInt(age);
        String soccer = req.getParameter("soccer");
        int studentSoccer = Integer.parseInt(soccer);
        Student student = new Student(name,studentAge,studentSoccer);
        studentDao.addStudent(student);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
